package com.icez.designmode

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.TextView
import androidx.fragment.app.FragmentActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.icez.recycleradapter.RecyclerAdapter
import com.icez.recycleradapter.holder.RecyclerViewHolder
import com.icez.verticalhorizontalrolinglibrary.RollingLayoutManager
import com.icez.videoplay.core.VideoPlayLayout
import com.icez.videoplay.enum.VideoPlayType

class MainActivity : FragmentActivity(), RollingLayoutManager.OnCurrentPositionListener {
    var rv: RecyclerView? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)


        rv = findViewById<RecyclerView>(R.id.rv)
        LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)
        val a = RollingLayoutManager(this, LinearLayoutManager.VERTICAL)
        rv?.layoutManager = a
        val list = ArrayList<String>()
        for (index in 0..30) {
            list.add("数据：" + index)
        }
        rv?.adapter = object : RecyclerAdapter<String>(this, R.layout.rv_item_layout, list) {
            override fun onBusinessOperation(holder: RecyclerViewHolder, position: Int) {
                val rv_item_tv = holder.getView<TextView>(R.id.rv_item_tv)
//                item_vpl?.initConfig(
//                    this@MainActivity,
//                    VideoPlayType.FACEBOOK,
//                    "3024261827613903",
//                    "1102100307234739"
//                )

                rv_item_tv?.text = mData?.get(position)
//                item_vpl?.initConfig(this@MainActivity,
//                    VideoPlayType.YOUTUBE,
//                    "AIzaSyAHY_R2haQAHpXzSOi0aVcBO2Eif0EWj0o",
//                    "R2iMq5LKXco", {
//                        item_vpl?.setPlayVideo()
//
//                    }, {
//
//                    })
            }
        }

        a.setOnCurrentPositionListener(this)
    }

    override fun currentPositionListener(view: View?, currentPosition: Int?) {
        Log.e("icez","当前索引："+currentPosition)
    }

    override fun currentDetachedPositionListener(view: View?, currentPosition: Int?) {

    }
}